/**
 *  Copyright 2010 Kyle O'Connor, Justin Arling, Mike Mercieca
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package edu.drexel.sd0910.ece01.aqmon.gui.wizard;

import javax.swing.JPanel;

/**
 * A base descriptor class used to reference a panel for the Wizard, as well as
 * provide general rules as to how the panel should behave.
 * 
 * @author Kyle O'Connor
 * 
 */
public class WizardPanelDescriptor {

	private static final String DEFAULT_PANEL_IDENTIFIER = "defaultPanelIdentifier";

	public static final FinishIdentifier FINISH = new FinishIdentifier();

	private Wizard wizard;
	private JPanel targetPanel;
	private Object panelIdentifier;

	/**
	 * Default constructor. The id and the Component panel must be set
	 * separately.
	 */
	public WizardPanelDescriptor() {
		panelIdentifier = DEFAULT_PANEL_IDENTIFIER;
		targetPanel = new JPanel();
	}

	/**
	 * @param targetPanel
	 * @param panelIdentifier
	 */
	public WizardPanelDescriptor(JPanel panel, Object id) {
		this.targetPanel = panel;
		this.panelIdentifier = id;
	}

	public Wizard getWizard() {
		return wizard;
	}

	public void setWizard(Wizard w) {
		this.wizard = w;
	}

	public JPanel getTargetPanel() {
		return targetPanel;
	}

	public void setTargetPanel(JPanel panel) {
		this.targetPanel = panel;
	}

	public Object getPanelIdentifier() {
		return panelIdentifier;
	}

	public void setPanelIdentifier(Object id) {
		this.panelIdentifier = id;
	}

	public WizardModel getWizardModel() {
		return wizard.getModel();
	}

	/**
	 * Override this class to provide the Object-based identifier of the panel
	 * that the user should traverse to when the Next button is pressed. Note
	 * that this method is only called when the button is actually pressed, so
	 * that the panel can change the next panel's identifier dynamically at
	 * runtime if necessary. Return null if the button should be disabled.
	 * Return FinishIdentfier if the button text should change to 'Finish' and
	 * the dialog should end.
	 * 
	 * @return Object-based identifier.
	 */
	public Object getNextPanelDescriptor() {
		return null;
	}

	/**
	 * Override this class to provide the Object-based identifier of the panel
	 * that the user should traverse to when the Back button is pressed. Note
	 * that this method is only called when the button is actually pressed, so
	 * that the panel can change the previous panel's identifier dynamically at
	 * runtime if necessary. Return null if the button should be disabled.
	 * 
	 * @return Object-based identifier
	 */
	public Object getBackPanelDescriptor() {
		return null;
	}

	/**
	 * Override this method to provide functionality that will be performed just
	 * before the panel is to be displayed.
	 */
	public void aboutToDisplayPanel() {

	}

	/**
	 * Override this method to perform functionality when the panel itself is
	 * displayed.
	 */
	public void displayingPanel() {

	}

	/**
	 * Override this method to perform functionality just before the panel is to
	 * be hidden.
	 */
	public void aboutToHidePanel() {

	}

	public static class FinishIdentifier {
		public static final String ID = "FINISH";
	}

}
